local skynet = require "skynet"
local cluster = require "skynet.cluster"
local mynode = skynet.getenv("node")

local CMD = {}

function CMD.pingback(source_node, source_srv, count)
    skynet.error("["..skynet.self().."] recv pingback count="..count)
    skynet.sleep(100)
    cluster.send(source_node, source_srv, "pingback", mynode, skynet.self(), count+1)
end

function CMD.start(target_node, target)
    --向target_node节点的target服务发送ping消息, 后面三个是附带的参数, skynet.self()代表自身服务的地址
    cluster.send(target_node, target, "pingback", mynode, skynet.self(), 1)
end

skynet.start(function()
    --session-对请求的标识, source-消息源服务的地址
    skynet.dispatch("lua", function(session, source, cmd, ...)
      local f = assert(CMD[cmd])
      f(...)
    end)
end)